﻿using System;
using System.Text;
using WeiXinPF.Common;
using WeiXinPF.Templates;

namespace WeiXinPF.Web.modules.cdrt.smart
{
    /// <summary>
    /// 权威发布
    /// </summary>
    public partial class authority_announce : TBasePage
    {
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!string.IsNullOrEmpty(errInitTemplates))
            {
                Response.Write(errInitTemplates);
                return;
            }

            var requestOpenId = MyCommFun.RequestOpenid();
            if (MyCommFun.IsEmptyOpenId(requestOpenId))
            {
#if DEBUG
                requestOpenId = ConfigurationHelper.GetDebugOpenId();
#else
                var cid = MyCommFun.RequestParam("cid");
                StringBuilder paraBuilder = new StringBuilder();
                paraBuilder.AppendFormat("wid={0}", wid);
                paraBuilder.Append("&");
                paraBuilder.AppendFormat("cid={0}", cid);

                var thisUrl = string.Format("{0}/modules/cdrt/smart/authority_announce.aspx?{1}", 
                    MyCommFun.getWebSite(), paraBuilder.ToString());
                var bll = new BLL.wx_userweixin();
                var uWeiXinModel = bll.GetModel(wid);
                base.OAuth2BaseProc(uWeiXinModel, "authority_announce", thisUrl);
#endif
            }

            tPath = MyCommFun.GetRootPath() + "/modules/cdrt/smart/templates/authority_announce.html";
            TemplateMgr template = new TemplateMgr(tPath, wid);
            template.tType = TemplateType.Class;
            template.openid = MyCommFun.RequestOpenid();

            template.OutPutHtml(templateIndexFileName, wid);
        }
    }
}